﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Data;

namespace BoriPeter.FitnessJournal8.Converters
{
    /// <summary>
    /// Converts bool value to Visibility property. If the control is visible for true or false depends on the parameter
    /// </summary>
    public class VisibilityConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, string language)
        {
            var sValue = value.ToString();
            var bValue = bool.Parse(sValue);

            var sParameter = parameter.ToString();
            var bParameter = bool.Parse(sParameter);

            if (bValue ^ bParameter)
                return Visibility.Collapsed;
            else
                return Visibility.Visible;
        }

        public object ConvertBack(object value, Type targetType, object parameter, string language)
        {
            throw new NotImplementedException();
        }
    }
}
